this.parent();
this._window = window;
this._dialog = null;
+ this._tracked = undefined;
this._timeoutId = 0;
+ this._windowFocusChangedId = 0;
+ this._keyFocusChangedId = 0;
},
get window() {
this.response(Meta.CloseDialogResponse.FORCE_CLOSE);
},
+ _onFocusChanged() {
+ if (Meta.is_wayland_compositor())
+ return;
+
+ let focusWindow = global.display.focus_window;
+ let keyFocus = global.stage.key_focus;
+
+ let shouldTrack;
+ if (focusWindow != null)
+ shouldTrack = focusWindow == this._window;
+ else
+ shouldTrack = keyFocus && this._dialog.contains(keyFocus);
+
+ if (this._tracked === shouldTrack)
+ return;
+
+ if (shouldTrack)
+ Main.layoutManager.trackChrome(this._dialog,
+ { affectsInputRegion: true });
+ else
+ Main.layoutManager.untrackChrome(this._dialog);
+
+ // The buttons are broken when they aren't added to the input region,
+ // so disable them properly in that case
+ this._dialog.buttonLayout.get_children().forEach(b => {
+ b.reactive = shouldTrack;
+ });
+
+ this._tracked = shouldTrack;
+ },
+
vfunc_show() {
if (this._dialog != null)
return;
return GLib.SOURCE_CONTINUE;
});
+ this._windowFocusChangedId =
+ global.display.connect('notify::focus-window',
+ this._onFocusChanged.bind(this));
+
+ this._keyFocusChangedId =
+ global.stage.connect('notify::key-focus',
+ this._onFocusChanged.bind(this));
+
this._addWindowEffect();
this._initDialog();
{ scale_y: 1,
transition: 'linear',
time: DIALOG_TRANSITION_TIME,
- onComplete: () => {
- Main.layoutManager.trackChrome(this._dialog, { affectsInputRegion: true });
- }
+ onComplete: this._onFocusChanged.bind(this)
});
},
GLib.source_remove(this._timeoutId);
this._timeoutId = 0;
+ global.display.disconnect(this._windowFocusChangedId)
+ this._windowFocusChangedId = 0;
+
+ global.stage.disconnect(this._keyFocusChangedId);
+ this._keyFocusChangedId = 0;
+
let dialog = this._dialog;
this._dialog = null;
this._removeWindowEffect();